#coding:utf-8
import time
import logging
import logging.config
logging.config.fileConfig("logger.conf")  #导入配置文件
from API.Instruments.DMM.gdm8261a import GDM8261A
from API.Instruments.PowerSupply.gwinstek import GWinstek


dmm = GDM8261A(serial="COM6")
pwr = GWinstek(gpib_addr=8)

print pwr.getid()
print dmm.getid()

pwr.clear()
dmm.clear()

pwr.setV(1, 1, 0.5)
pwr.outOn()

logger = logging.getLogger("pwrdmm") #通过关键字"pwrdmm"调用logger.conf，使当前程序结构简化

logger.info("Power test begin")

while True:
    for i in range(1, 11, 1):
        pwr.setV(1, i, 0.5)
        time.sleep(1)
        pv = dmm.getV()
        deviation = i - pv
        if deviation <= 0.01:
            logger.debug( "The Voltage now is %s, the devisation is %s, Test PASS!" %(pv, deviation))
        else:
            logger.debug("The Voltage now is %s, Test Fail!" %pv)
        # logger.info("The Voltage now is %s" %dmm.getV())